# myapp/urls.py

from django.urls import path, re_path
from . import views
from .views import index_view, dynamic_url_view,redirect_to_another_view
from django.views.generic import RedirectView

app_name = 'myapp'  # 设置命名空间

urlpatterns = [
    path('', views.index_view, name='index'),  # 新增首页路由
    path('', views.hello_view, name='hello'),  # 唯一名称
    path('add/<int:a>/<int:b>/', views.add_view, name='add'),  # 唯一名称
    re_path(r'^post-(\d+)/$', views.post_view, name='post'),  # 唯一名称
    path('dynamic-url/', dynamic_url_view, name='dynamic_url'), # 动态链接视图
    path('redirect-to-home/', RedirectView.as_view(url='/')),  # 重定向到首页
    path('redirect-to-index/', redirect_to_another_view, name='redirect_to_index'),  # 新的重定向视图
]
